<script type="text/javascript">
function test() {
	var target = $("#url").val();
	var pattern = $("#searchPattern").val();
	if (target == "" || target == null) {
		$("#url").css("border", "solid 3px red");
		return;
	}
	$.post('/extract.php', { url: target, pattern: pattern},
		function(data) {
			$("#clippedData").val(data);
		}
	);
}

function loadSource() {
	var target = $("#url").val();
	if (target == "" || target == null) {
		$("#url").css("border", "solid 3px red");
		return;
	}
	target = '/http.php?url=' + target;
	$.ajax({
		url: target, 
		success: function(data) {
			$("#pageSource").val(data);
		}, 
		error: function() {
			alert('e');
		}
	});
}

</script>
<?php
//echo $javascript->link('prototype');
echo $form->create('source');
//echo $form->input('update_frequency');
?>
<label for="sourceAddress">URL</label><br />
<input id="sourceAddress" name="sourceAddress" type="text" size="50" value="<?php ?>" />
<input id="cratch" type="button" value="Reload" onclick="try {loadSource();} catch(ex) {alert(ex);};" />
<div>
<label for="pageSource">Page Source</label><br />
<textarea id="pageSource" name="pageSource" cols="3" rows="2" style="width:600px;height:150px;"></textarea>
</div>
<div>
<label for="sourceSearchPattern">Search Pattern</label><br />
<textarea id="sourceSearchPattern" name="sourceSearchPattern" cols="3" rows="2" style="height:50px;" class="postbox">/<title>.+</i</textarea>
<br /><input id="extract" type="button" value="Extract" onclick="try {test();} catch(ex) {alert(ex);};" />
</div>
<div>
<label for="sourceUpdateFrequency">Update Frequency</label><br />
<select id="sourceUpdateFrequency" name="sourceUpdateFrequency">
	<option value="1">1分钟</option>
	<option value="5">5分钟</option>
	<option value="15">15分钟</option>
	<option value="30">半小时</option>
	<option value="60">一小时</option>
</select>
</div>
<div>
<label for="clippedData">Clipped Data</label><br />
<textarea id="clippedData" name="clippedData" cols="5" rows="3" style="height:120px;">sample data</textarea>
</div>
<?php echo $form->end('Save'); ?>
